<script setup>
import keepAliveStore from "@/store/modules/keepalive";
import IframeIndex from "@/views/kjxy/index";
const route = useRoute();
const keepStore = keepAliveStore();
const keepAliveList = computed(() =>
  keepStore.keepAliveList.filter(
    (n) =>
      ![
        "Logistics-settingsMerchantAdd",
        // "Logistics-settingsChannelAdd",
        "Finance-manageInitial-billsDetail",
        "Finance-manageBills-paymentAdd",
        "Finance-manageBills-paymentDetail",
        "Logistics-settingsChannelTransport-cost",
        "logistics-settingsBill-logisticsDesign",
        "Export-rebatesForecast-listDetails",
        "KjxyIndex",
      ].includes(n)
  )
);
const isIframePage = ref(false);
const IframeVisited = ref(false);
watch(
  () => route.path,
  (value) => {
    if (value === "/kjxy/index") {
      IframeVisited.value = true;
      isIframePage.value = true;
    } else {
      isIframePage.value = false;
    }
  },
  {
    immediate: true,
  }
);
watch(
  () => keepStore.keepAliveList,
  (val) => {
    let kjxy = val?.find((item) => item == "KjxyIndex");
    if (!kjxy) {
      IframeVisited.value = false;
    }
  }
);
</script>

<template>
  <!-- 在 qiankun 环境中不显示菜单 -->
  <!-- <div v-if="!qiankunWindow.__POWERED_BY_QIANKUN__" class="flex my-2 justify-center gap-2">
    <div v-for="(item, index) in routes" :key="index" class="hover:text-blue-500">
      <router-link :to="item.path">{{ item.meta.title || item.name }}</router-link>
    </div>
  </div> -->
  <IframeIndex v-if="IframeVisited" v-show="isIframePage"></IframeIndex>
  <router-view v-slot="{ Component }">
    <keep-alive :include="keepAliveList">
      <component :is="Component" />
    </keep-alive>
  </router-view>
</template>
